<template>
  <div class="risk">
    <page-list
      url="/ChsDangerNotPorduce/GetTaskDetailList"
      :params="params"
      @initActive="_initActive"
      @initList="_initList"
      ref="eagleTabPageList"
    >
      <eagle-cell class="card" v-for="(item, index) in list" :key="index">
        <template v-if="active === 0">
          <div class="warn_item">
              <div @click="goToDetail(item)">
                <div class="f14">
                  <div>
                    {{ index + 1 }}、隐患描述：{{ item.HiddenDangerDesc }}
                  </div>
                </div>

                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="24">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_task.png"
                      alt=""
                    />{{ "暂无区域" }}</eagle-col
                  >
                </eagle-row>

                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="24">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_area.png"
                      alt=""
                    />隐患区域：{{ item.HiddenDangerArea || "暂无区域" }}</eagle-col
                  >
                </eagle-row>

                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="24">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_task.png"
                      alt=""
                    />所属任务：{{ item.CheckTaskName }}</eagle-col
                  >
                </eagle-row>

                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="24">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_kind.png"
                      alt=""
                    />{{ item.LGDFullName }}</eagle-col
                  >
                </eagle-row>

                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="10">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_user.png"
                      alt=""
                    />{{ item.CreateChnName }}</eagle-col
                  >
                  <eagle-col span="14">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />{{ getDateTime(item.CreateDate) }}</eagle-col
                  >
                </eagle-row>

                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="24">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />状态：{{ item.StatusName }}</eagle-col
                  >
                </eagle-row>
            </div>
            <div class="dep_btm">
                  <!-- 编辑按钮 -->
                 <div
                    class="btm_item"
                    @click.stop="HiddenDangerEdit(item)"
                    style="margin-right: 15px" 
                    v-if="openType == 'Edit'"
                  >
                    <img src="@/assets/Images/AppIcon/icon_exam_add.png" 
                    alt="" />
                    <div>编辑</div>
                  </div>

                  <!-- 删除按钮 -->
                  <div
                    class="btm_item"
                    @click.stop="Deletedanger(item)"
                    style="margin-right: 15px" 
                    v-if="openType == 'Edit'"
                  >
                    <img src="@/assets/Images/AppIcon/icon_list_distribution.png" 
                    alt="" />
                    <div class="mr-10">删除</div>
                  </div>
                </div>
          </div>
            
        </template>
      
      </eagle-cell>
    </page-list>
  </div>
</template>

<script>
import { getDateTime } from "@/utils/getDate";
import PageList from "./PageList.vue"

export default {
  components :{
    PageList
  },
  data() {
    return {
      CtCode: this.$route.query.ctCode,
      openType : this.$route.query.openType,
      params:
        {
          ctCode: this.$route.query.ctCode,
        },
        
      list: [],
      active: 0,
      
    };
  },
  created() {
  },
  methods: {
    _initActive(active) {
      this.active = active;
    },
    _initList(list) {
      this.list = list;
    },
    getDateTime(value) {
      return getDateTime(value);
    },
    goDetail(item) {
      this.$router.push({
        path: "/OtherDanger/DangerCheckDetailView",
        query: { id: item.ID,type:"verified" },
      });
    },
    goToDetail(item) {
      this.$router.push({
        path: "/FeedSafetyProduction/feedhiddendangerDetail",
        query: { id: item.ID },
      });
    },
    getFile(equipmentCode) {
      this.$router.push({
        path: "/Equipment/safetyfile",
        query: { equipmentCode: equipmentCode },
      });
    },
    // 编辑设备信息
    edit(equipmentCode) {
      this.$router.push({
        path: "/Equipment/Edit",
        query: { equipmentCode: equipmentCode },
      });
      this.$router.push("");
    },
    // 设备检验
    editCheck(equipmentCode) {
      this.$router.push({
        path: "/Equipment/editcheck",
        query: { equipmentCode: equipmentCode },
      });
    },
    HiddenDangerEdit(item) {
      this.$router.push({
        path: "/FeedSafetyProduction/HidddangerEdit",
        query: { 
          id: item.ID,
          TaskId : item.TaskId
         },
      });
    },
    // 删除按钮
    Deletedanger(item) {
      this.$dialog
        .confirm({
          title: "询问",
          message: "您确定要删除该条记录吗？",
        })
        .then(() => {
          let params = { id: item.ID };
          this.$axios
          // GET /api/ChsDangerNotPorduce/Delete/{id}
            .get('/OtherDangerCheckTaskDetailJG/DeleteTaskDetail', {
              params: params,
            })
            .then((res) => {
              this.$toast("删除成功");
              this.$router.push({
                path:'/FeedSafetyProduction/feedhiddendanger'
              })
            });
        })

    }
  },
};
</script>

<style lang="less" scoped>
.dep_sort {
  img {
    height: 15px;
    width: 15px;
    margin-right: 5px;
  }
}
.dep_btm {
  display: flex;
  justify-content: flex-end;
  .btm_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}
</style>
